package com.example.springbootstartermqttprovider.test;

import cn.hutool.core.util.NumberUtil;

import java.util.Random;

public class MathUtils {


    public static void main(String[] args) {

        // c4:a8:28:40:b7:f1
        //c4a82840b7f1
                // C4A82840B7F1

        //device_bike_info:001061:c4a82840b7f1
        //overShootNum:1080,recordNum:114633,orderCount:0,yesOrderCount:0,weekOrderCount:0,yesOverShootNum:597,
        // weekOverShootNum:0,yesOverStopNum:38,weekOverStopNum:0
//        String calculation = MathUtils.getCalculation(Integer.parseInt(String.valueOf("1096")), Integer.parseInt(String.valueOf("597")));
//        System.out.println(calculation);
        Random random = new Random();
        boolean b = random.nextInt(11 / 10) == 0;
        System.out.println(b);
        int i = random.nextInt(1/ 10) == 0 ? 1 : random.nextInt(1/ 10);
        System.out.println(i);


        //c4:a8:28:40:a0:88
        //device_bike_info:001061:c4a82840a088
        //device_bike_info:001061:c4a82840b7f1
        //device_bike_info:001061:c4a82840aa26
        //device_bike_info:001061:c4a82840cee3
        //device_bike_info:001061:c4a8284097b5
        //device_bike_info:001061:c4a82840da26




    }


    private static String getCalculation(int sum, int sum2) {
        String sign = sum - sum2 > 0 ? "+" : "-";
        int count = Math.abs(sum - sum2);
        return sign + calculationPercentage(count, sum2);
    }

    private static String calculationPercentage(Integer num1, Integer num2) {
        if (num1 == 0 && num2 > 0) return "0.00%";
        if (num1 > 0 && num2 == 0) return "100.00%";
        if (num1 == 0 && num2 == 0) return "0.00%";

//        DecimalFormat df = new DecimalFormat("######.00%");//传入格式模板
//        Number number = (float) num1 / (float) num2;
        return NumberUtil.decimalFormat("######.00%", NumberUtil.div(num1, num2).floatValue());
//        return df.format(number);
    }

}
